﻿using System;
using System.Collections.Generic;
using Infrastructure;
using OpenAuth.App.Interface;
using OpenAuth.Repository.Domain;
using OpenAuth.Repository.Interface;

namespace OpenAuth.App
{
    /// <summary>
    /// 门诊结算
    /// </summary>
    public class CheckOutOrderMZApp:BaseApp<CheckOutOrderMZEntity>
    {  
        private IAuth _auth;
        public CheckOutOrderMZApp(IUnitWork unitWork, 
            IRepository<CheckOutOrderMZEntity> repository,
            IAuth auth) : base(unitWork, repository)
        { 
            _auth = auth;
        }

        public void Add(CheckOutOrderMZEntity entity)
        {
            Repository.Add(entity);
        }    
        /// <summary>
        /// 
        /// </summary>
        /// <param name="jszt">就诊状态,开始结算0  结算成功1 结算失败2</param>
        /// <returns></returns>
        public List<CheckOutOrderMZEntity> GetListByjszt(int jszt)
        {
            var query = Repository.Find(x => x.jszt ==  jszt);
            var items = query.MapToList<CheckOutOrderMZEntity>();
            return items;
        }
        public void Update(CheckOutOrderMZEntity obj)
        {
           // var user = _auth.GetCurrentUser().User;
            UnitWork.Update<CheckOutOrderMZEntity>(
                u => u.Id == obj.Id, 
                u => new CheckOutOrderMZEntity
            {
                jszt = obj.jszt,
                message = obj.message,
                UpdateDateTime = DateTime.Now,
                patid = obj.patid,
                ghxh = obj.ghxh,
                sjh = obj.sjh,
                ptlsh = obj.ptlsh,
                cfxhhj = obj.cfxhhj,
                zje = obj.zje,
                yfje = obj.yfje,
                zffs = obj.zffs,
                zfje = obj.zfje,
                zflsh = obj.zflsh,
                zfsj = obj.zfsj,
                isynzh = obj.isynzh,
                iszfjs = obj.iszfjs,
                ybrc=obj.ybrc
                //UpdateTime = DateTime.Now,
                //UpdateUserId = user.Id,
                //UpdateUserName = user.Name
                //todo:补充或调整自己需要的字段
            });

        }
    }
}